import 'package:json_annotation/json_annotation.dart';

part 'oss_sts_api.g.dart';

@JsonSerializable()
class ResponseOssStsApi {
  final OssCredentialsBean credentials;
  final String region;
  final String bucket;
  final OssCallback callback;
  final String dir;
  final String uploadFileName;

  ResponseOssStsApi({
    required this.credentials,
    required this.region,
    required this.bucket,
    required this.callback,
    required this.dir,
    required this.uploadFileName,
  });

  factory ResponseOssStsApi.fromJson(Map<String, dynamic> json) =>
      _$ResponseOssStsApiFromJson(json);

  Map<String, dynamic> toJson() => _$ResponseOssStsApiToJson(this);
}

@JsonSerializable()
class OssCredentialsBean {
  final String accessKeyId;
  final String accessKeySecret;
  final String expiration;
  final String securityToken;

  OssCredentialsBean({
    required this.accessKeyId,
    required this.accessKeySecret,
    required this.expiration,
    required this.securityToken,
  });

  factory OssCredentialsBean.fromJson(Map<String, dynamic> json) =>
      _$OssCredentialsBeanFromJson(json);

  Map<String, dynamic> toJson() => _$OssCredentialsBeanToJson(this);
}

@JsonSerializable()
class OssCallback {
  final String callbackUrl;
  final String callbackBody;
  final String callbackBodyType;
  final bool callbackSNI;
  final OssCustomValue customValue;

  OssCallback({
    required this.callbackUrl,
    required this.callbackBody,
    required this.callbackBodyType,
    required this.callbackSNI,
    required this.customValue,
  });

  factory OssCallback.fromJson(Map<String, dynamic> json) =>
      _$OssCallbackFromJson(json);

  Map<String, dynamic> toJson() => _$OssCallbackToJson(this);
}

@JsonSerializable()
class OssCustomValue {
  @JsonKey(name: 'upload_file_name')
  final String uploadFileName;
  final String uid;

  OssCustomValue({required this.uploadFileName, required this.uid});

  factory OssCustomValue.fromJson(Map<String, dynamic> json) =>
      _$OssCustomValueFromJson(json);

  Map<String, dynamic> toJson() => _$OssCustomValueToJson(this);
}
